package conf

import (
	"github.com/spf13/viper"
	"honeyweb/log"
)

func ReadConfFromFile(file string, conf interface{}) error {
	v := viper.New()
	v.SetConfigFile(file)
	if err := v.ReadInConfig(); err != nil {
		log.S().Debugf("read mysql config file: %s error: %v", file, err)
		return   err
	}

	if err := v.Unmarshal(conf); err != nil {
		log.S().Debug("Unmarshal config file: %s error: %v", file, err)
		return err
	}
	log.S().Debugf("read file: %s conf: %+v",file,  conf)
	return   nil
}
